home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr57 / mentc.zip / ESTRUCT.H < prev    next >
C/C++ Source or Header  |  1993-06-01  |  30KB  |  960 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.11
  3.  
  4.             written by Daniel Lawrence
  5.             based on code by Dave G. Conroy,
  6.                 Steve Wilhite and George Jones
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE      /* don't use their definitions...use ours     */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    AMIGA
  16. #undef    AMIGA
  17. #endif
  18. #ifdef    EGA
  19. #undef    EGA
  20. #endif
  21. #ifdef    CTRLZ
  22. #undef    CTRLZ
  23. #endif
  24.  
  25. /*    Program Identification.....
  26.  
  27.     PROGNAME should always be MicroEMACS for a distribution
  28.     unmodified version. People using MicroEMACS as a shell
  29.     for other products should change this to reflect their
  30.     product. Macros can query this via the $progname variable
  31. */
  32.  
  33. #define PROGNAME    "MicroEMACS"
  34. #define    VERSION        "3.11"
  35.  
  36. /*    Machine/OS definitions            */
  37. /*    [Set one of these!!]            */
  38.  
  39. #define AMIGA    0            /* AmigaDOS            */
  40. #define AOSVS    0            /* Data General AOS/VS        */
  41. #define AVIION    0            /* Data General AViiON        */
  42. #define BSD    0            /* UNIX BSD 4.2 and ULTRIX    */
  43. #define FINDER    0            /* Macintosh OS         */
  44. #define HPUX    0            /* HPUX HP 9000 minicomputer    */
  45. #define MPE    0            /* HP MPE/XL            */
  46. #define MSDOS    0            /* MS-DOS            */
  47. #define OS2    0            /* Microsoft or IBM OS/2    */
  48. #define SMOS    0            /* Supermax UNIX System V    */
  49. #define SUN    0            /* SUN v4.0            */
  50. #define TOS    0            /* ST520, TOS            */
  51. #define USG    0            /* UNIX system V        */
  52. #define V7    0            /* V7 UNIX or Coherent or BSD4.2*/
  53. #define VMS    0            /* VAX/VMS            */
  54. #define WMCS    0            /* Wicat's MCS            */
  55. #define XENIX    0            /* IBM-PC SCO XENIX        */
  56. #define WINNT    1            /* Windows NT            */
  57.  
  58. /*    Compiler definitions            */
  59. /*    [Set one of these!!]            */
  60. #define    ALCYON    0    /* ALCYON Atari ST compiler */
  61. #define    DGC    0    /* Data General AOS/VS C... */
  62. #define AZTEC    0    /* Aztec C 3.20e */
  63. #define DTL    0    /* DataLight C v3.12 */
  64. #define GCC    0    /* the GNU C compiler */
  65. #define LATTICE 0    /* Lattice 2.14 through 3.0 compilers */
  66. #define MSC    0    /* MicroSoft C compile version 3 & 4 & 5.1 */
  67. #define MWC    0    /* Mark Williams C */
  68. #define TURBO    0    /* Turbo C/MSDOS */
  69. #define UNIX    0    /* a standard UNIX compiler (cc) */
  70. #define    ZTC    0    /* Zortech C/C++ 1.02 thru 2.10 under MSDOS */
  71.  
  72. /*      Machine stack growth direction.                     */
  73. /*  [Set this to 1 if your machine stack grows UP!!!]       */
  74. /*      data general mv/eclipse series stack grows up.      */
  75. /*      dec vax series stack grows down... got it???        */
  76.  
  77. #define STACK_GROWS_UP  0
  78.  
  79. /*    Debugging options    */
  80. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  81. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  82. #define    RAMTRCK    0    /* send debug info to MALLOC.DAT */
  83.  
  84. /*   Special keyboard/network definitions         */
  85.  
  86. #define ATKBD    0        /* AT-style keyboard with F11, F12 & grey keys */
  87. #define WANGPC    0        /* WangPC - mostly escape sequences    */
  88. #define VT100    0        /* Handle VT100 style keypad - NOT VMS.    */
  89. #define    NOVELL    0        /* IBMPC Novell NetWare flag! */
  90. #define KEYPAD    0        /* VMS - turn on and off application    */
  91.                 /* keypad automatically */
  92. #define XONDATA    0        /* VMS - set to force /NOTTSYNC/NOHOSTSY */
  93. #define    RMSIO    0        /* VMS - skip the rotten C runtime and    */
  94.                 /* use RMS directly            */
  95. #define OPTMEM    0        /* VMS 5.0 and up - use a less standard */
  96.                 /* but more efficient memory allocator    */
  97.  
  98. /*    Terminal Output definitions        */
  99. /*    [Set one of these!!]            */
  100.  
  101. #define ANSI    0            /* ANSI escape sequences    */
  102. #define DASHER    0            /* DG Dasher 2xx/4xx crts    */
  103. #define DG10    0            /* Data General system/10    */
  104. #define FMR    0            /* Fujitsu FMR series driver    */
  105. #define HP110    0            /* HP110 screen driver        */
  106. #define HP150    0            /* HP150 screen driver        */
  107. #define IBMPC    0            /* IBM-PC CGA/MONO/EGA/VGA drvr    */
  108. #define MAC    0            /* Macintosh            */
  109. #define NEC    0            /* NEC-9801VM driver        */
  110. #define OS2NPM    0            /* OS/2 non-Presentation Mgr.    */
  111. #define RAINBOW 0            /* Use Rainbow fast video.    */
  112. #define SMG    0            /* SMG library on VMS        */
  113. #define ST52    0            /* Atari 520/1040ST screen    */
  114. #define TERMCAP 0            /* Use TERMCAP            */
  115. #define TIPC    0            /* TI Profesional PC driver    */
  116. #define VT52    0            /* VT52 terminal (Zenith).    */
  117. #define Z309    0            /* Zenith 100 PC family    driver    */
  118. #define NTCON    1            /* Windows NT Console        */
  119.  
  120. /*    Windowing system style (pick one)                */
  121.  
  122. #define    WINDOW_TEXT    0        /* Text mode.... simple updates    */
  123. #define    WINDOW_XVT    0        /* using XVT/any platform    */
  124. #define    WINDOW_MSWIN    0        /* MicroSoft Windows        */
  125. #define    WINDOW_X    0        /* X/Unix            */
  126.  
  127. /*    Language text options    (pick one)                */
  128.  
  129. #define ENGLISH 1
  130. #define    FRENCH    0
  131. #define    SPANISH    0
  132. #define    GERMAN    0
  133. #define    DUTCH    0
  134. #define PLATIN    0
  135. #define    JAPAN    0
  136. #define    LATIN    0
  137.  
  138. /*    Configuration options    */
  139.  
  140. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  141. #define DEBUGM    0    /* $debug triggers macro debugging        */
  142. #define    LOGFLG    0    /* send all executed commands to EMACS.LOG    */
  143. #define    VISMAC    0    /* update display during keyboard macros    */
  144. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  145. #define    CLEAN    0    /* de-alloc memory on exit            */
  146. #define    CALLED    0    /* is emacs a called subroutine? or stand alone */
  147.  
  148. #define REVSTA    1    /* Status line appears in reverse video     */
  149. #define    COLOR    0    /* color commands and windows            */
  150.  
  151. #define FILOCK    0    /* file locking under unix BSD 4.2        */
  152. #define    ISRCH    0    /* Incremental searches like ITS EMACS        */
  153. #define    FLABEL    0    /* function key label code [HP150]        */
  154. #define    CRYPT    0    /* file encryption enabled?            */
  155. #define MAGIC    1    /* include regular expression matching?        */
  156. #define MOUSE    0     /* Include routines for mouse actions        */
  157. #define    NOISY    0    /* Use a fancy BELL if it exists        */
  158. #define CTAGS    0    /* include vi-like tagging?            */
  159. #define    SPEECH    0    /* spoken EMACS, for the sight impared [not ready] */
  160. #define    VARARG    1    /* use varargs.h for mlwrite()            */
  161.  
  162. /*    Character set options        */
  163. /*    [Set one of these!!]        */
  164. #define ASCII    1    /* always using ASCII char sequences for now    */
  165. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  166.  
  167. /* handle constant and voids properly */
  168.  
  169. #if    VMS
  170. #define    CONST    readonly
  171. #define    VOID    void
  172. #define NOSHARE noshare
  173. #else
  174. #if    AOSVS
  175. #define CONST $shared $align(1)     /* fake a  const */
  176. #define    VOID
  177. #define NOSHARE $low32k $align(1)   /* attempt to optimize read/write vars. */
  178. #else
  179. #ifdef WINNT
  180. #define CONST const
  181. #define VOID void
  182. #define NOSHARE
  183. #else
  184. #ifdef    __STDC__
  185. #define    CONST    const
  186. #define    VOID    void
  187. #define    NOSHARE
  188. #else
  189. #define    CONST
  190. #define    VOID
  191. #define NOSHARE
  192. #endif
  193. #endif
  194. #endif
  195. #endif
  196.  
  197. /*    System dependant library redefinitions, structures and includes */
  198.  
  199. /*    the following define allows me to initialize unions...
  200.     otherwise we make them structures (like the keybinding table)  */
  201.  
  202. /*    multibyte character support?    */
  203.  
  204. #if    NEC || FMR
  205. #define    DBCS    1    /* double byte character sets enabled */
  206. #define    INSDEL    1    /* use insert/delete line display optimizations */
  207.  
  208. /* define DBCS prefix bytes */
  209. #define    is2char(ch) (((ch&0xff) >= 0x81 && (ch&0xff) <= 0x9f) || ((ch&0xff) >=0xe0 && (ch&0xff) <= 0xfc))
  210.  
  211. #else
  212. #define    DBCS    0
  213. #define    INSDEL    0
  214. #endif
  215.  
  216. /*    Prototypes in use?    */
  217.  
  218. #if    MSC || TURBO || DTL || VMS || GCC || ZTC || WINNT
  219. #define    PROTO    1
  220. #else
  221. #define    PROTO    0
  222. #endif
  223.  
  224. #if    __STDC__ && (GCC == 0)    /* if ANSI C compatible */
  225. #define    ETYPE    union
  226. #else
  227. #define    ETYPE    struct
  228. #endif
  229.  
  230. #if MSDOS & (TURBO | MSC | TIPC)
  231. #define    NEAR
  232. #define    DNEAR
  233. #define    PASCAL pascal
  234. #define    CDECL cdecl
  235. #else
  236. #if MSDOS & ZTC
  237. #define    NEAR
  238. #define    DNEAR
  239. #define    PASCAL _pascal
  240. #define    CDECL _cdecl
  241. #else
  242. #ifdef WINNT
  243. #undef NEAR
  244. #undef DNEAR
  245. #undef PASCAL
  246. #undef CDECL
  247. #undef HIBYTE
  248. #define NEAR
  249. #define    DNEAR
  250. #define    PASCAL _stdcall
  251. #define    CDECL _stdcall
  252. #else
  253. #define NEAR
  254. #define    DNEAR
  255. #define    PASCAL
  256. #define    CDECL
  257. #endif
  258. #endif
  259. #endif
  260.  
  261. #ifdef WINNT
  262. #include <stdlib.h>
  263. #include <string.h>
  264. #endif
  265.  
  266. #if    TURBO
  267. #include      <dos.h>
  268. #include      <mem.h>
  269. #undef peek
  270. #undef poke
  271. #define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  272. #define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  273. #endif
  274.  
  275. #if    LATTICE & MSDOS
  276. /* you may have to remove this one definition with LATTICE version
  277.    3.2 and above                          */
  278. #define    unsigned
  279. #endif
  280.  
  281. #if    AZTEC
  282. #undef    putc
  283. #undef    getc
  284. #if    MSDOS
  285. #define    getc    a1getc
  286. #define    int86    sysint
  287. #define    intdos(a, b)    sysint(33, a, b)
  288. #define    inp    inportb
  289. #define    outp    outportb
  290. #else
  291. #define getc    agetc
  292. #endif
  293. #define putc    aputc
  294.  
  295. struct XREG {
  296.     unsigned ax,bx,cx,dx,si,di,ds,es;
  297. };
  298.  
  299. struct HREG {
  300.     char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  301. };
  302.  
  303. union REGS {
  304.     struct XREG x;
  305.     struct HREG h;
  306. };
  307.  
  308. struct SREGS {
  309.     unsigned cs, ss, ds, es;
  310. };
  311. #endif
  312.  
  313. #if    MSDOS & DTL
  314. #include    <dos.h>
  315. #endif
  316.  
  317. #if    MSDOS & MWC
  318. #include    <dos.h>
  319. #define    int86(a, b, c)    intcall(b, c, a)
  320. #define    intdos(a, b)    intcall(a, b, DOSINT)
  321. #define    inp(a)        in(a)
  322. #define    outp(a, b)    out(a, b)
  323. #define    movmem(a, b, c)    memcpy(b, a, c)
  324.  
  325. struct XREG {
  326.     unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  327. };
  328.  
  329. struct HREG {
  330.     char al,ah,bl,bh,cl,ch,dl,dh;
  331.     unsigned int ds,es,flags;
  332. };
  333.  
  334. union REGS {
  335.     struct XREG x;
  336.     struct HREG h;
  337. };
  338. #endif
  339.  
  340. #if    MSDOS & MSC
  341. #include    <dos.h>
  342. #include    <memory.h>
  343. #define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  344. #define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  345. #define    movmem(a, b, c)        memcpy(b, a, c)
  346. #endif
  347.  
  348. #if    MSDOS & LATTICE
  349. #undef    CPM
  350. #undef    LATTICE
  351. #include    <dos.h>
  352. #undef    CPM
  353. #endif
  354.  
  355. /* System V doesn't name this the same as others */
  356. #if    USG | SUN | (OS2 & MSC)
  357. #define    movmem(a, b, c)        memcpy(b, a, c)
  358. #endif
  359.  
  360. /* this keeps VMS happy */
  361. #if    VMS
  362. #define    getname xgetname
  363. #define    unlink(a)    delete(a)
  364. #endif
  365.  
  366. /* some options for AOS/VS */
  367. #if     AOSVS
  368. #define ORMDNI  1
  369. #endif
  370.  
  371. /*    define some ability flags */
  372.  
  373. #if    IBMPC | Z309 | FMR | TIPC
  374. #define    MEMMAP    1
  375. #else
  376. #define MEMMAP    0
  377. #endif
  378.  
  379. #if    MSDOS | OS2 | V7 | USG | SMOS | HPUX | BSD | (TOS & MWC) | WMCS | SUN | MPE | WINNT
  380. #define    ENVFUNC    1
  381. #else
  382. #define ENVFUNC 0
  383. #endif
  384.  
  385. #if    MPE
  386. #define DIRSEPSTR    "."
  387. #define DIRSEPCHAR    '.'
  388. #else
  389. #if    TOS || MSDOS || OS2 || WINNT
  390. #define    DIRSEPSTR    "\\"
  391. #define    DIRSEPCHAR    '\\'
  392. #else
  393. #define DIRSEPSTR    "/"
  394. #define    DIRSEPCHAR    '/'
  395. #endif
  396. #endif
  397.  
  398. #define    DRIVESEPCHAR    ':'
  399.  
  400. #if    VARARG
  401. #if    USG || BSD || SUN || XENIX || HPUX || AVIION || MPE
  402. #define    VARG    1
  403. #define    SARG    0
  404. #include    <varargs.h>
  405. #else
  406. #define    VARG    0
  407. #define    SARG    1
  408. #include    <stdarg.h>
  409. #endif
  410. #endif
  411.  
  412. #if ZTC
  413. #include     <dos.h>
  414. #define      movmem(a, b, c) memcpy(b, a, c)
  415. #endif
  416.  
  417. /*    Emacs global flag bit definitions (for gflags)    */
  418.  
  419. #define GFREAD    1    /* read first file in at startup */
  420. #define GFSDRAW    2    /* suppress a screen redraw */
  421.  
  422. /*    internal constants    */
  423.  
  424. #define NBINDS    300            /* max # of bound keys        */
  425. #if    AOSVS | VMS
  426. #define    NFILEN    256
  427. #else
  428. #define NFILEN    80            /* # of bytes, file name    */
  429. #endif
  430. #define NBUFN    32            /* # of bytes, buffer name    */
  431. #define NLINE    256            /* # of bytes, input line    */
  432. #define    NSTRING    128            /* # of bytes, string buffers    */
  433. #define NKBDM    256            /* # of strokes, keyboard macro */
  434. #define NPAT    128            /* # of bytes, pattern        */
  435. #define HUGE    1000            /* Huge number            */
  436. #define    NLOCKS    100            /* max # of file locks active    */
  437. #define    NCOLORS    16            /* number of supported colors    */
  438. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  439. #define    NBLOCK    16            /* line block chunk size    */
  440. #define    NVSIZE    10            /* max #chars in a var name    */
  441. #define NMARKS    10            /* number of marks        */
  442.  
  443. #define CTRL    0x0100        /* Control flag, or'ed in        */
  444. #define META    0x0200        /* Meta flag, or'ed in            */
  445. #define CTLX    0x0400        /* ^X flag, or'ed in            */
  446. #define SPEC    0x0800        /* special key (function keys)        */
  447. #define MOUS    0x1000        /* alternative input device (mouse)    */
  448. #define    SHFT    0x2000        /* shifted (for function keys)        */
  449. #define    ALTD    0x4000        /* ALT key...                */
  450.  
  451. #define    BINDNUL    0        /* not bount to anything        */
  452. #define    BINDFNC    1        /* key bound to a function        */
  453. #define    BINDBUF    2        /* key bound to a buffer        */
  454.  
  455. #define    FORWARD        0    /* doing things forward            */
  456. #define    BACKWARD    -1    /* doing things in reverse        */
  457.  
  458. #ifdef    FALSE
  459. #undef    FALSE
  460. #endif
  461. #ifdef    TRUE
  462. #undef    TRUE
  463. #endif
  464.  
  465. #define FALSE    0            /* False, no, bad, etc.     */
  466. #define TRUE    1            /* True, yes, good, etc.    */
  467. #define ABORT    2            /* Death, ^G, abort, etc.    */
  468. #define    FAILED    3            /* not-quite fatal false return    */
  469.  
  470. #define STOP    0            /* keyboard macro not in use    */
  471. #define    PLAY    1            /*          playing    */
  472. #define    RECORD    2            /*          recording    */
  473.  
  474. /*    Competion types        */
  475.  
  476. #define    CMP_BUFFER    0
  477. #define    CMP_COMMAND    1
  478. #define    CMP_FILENAME    2
  479.  
  480. /*    Directive definitions    */
  481.  
  482. #define DIF        0
  483. #define DELSE        1
  484. #define DENDIF        2
  485. #define DGOTO        3
  486. #define DRETURN        4
  487. #define DENDM        5
  488. #define DWHILE        6
  489. #define    DENDWHILE    7
  490. #define    DBREAK        8
  491. #define DFORCE        9
  492.  
  493. #define NUMDIRS     10
  494.  
  495. /*
  496.  * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  497.  * the scan routines.
  498.  */
  499. #define PTBEG    0    /* Leave the point at the beginning on search    */
  500. #define    PTEND    1    /* Leave the point at the end on search        */
  501. #define    FORWARD    0            /* forward direction        */
  502. #define REVERSE    1            /* backwards direction        */
  503.  
  504. #define FIOSUC    0            /* File I/O, success.        */
  505. #define FIOFNF    1            /* File I/O, file not found.    */
  506. #define FIOEOF    2            /* File I/O, end of file.    */
  507. #define FIOERR    3            /* File I/O, error.        */
  508. #define    FIOMEM    4            /* File I/O, out of memory    */
  509. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  510. #define    FIODEL    6            /* Can't delete/rename file    */
  511.  
  512. #define CFCPCN    0x0001            /* Last command was C-P, C-N    */
  513. #define CFKILL    0x0002            /* Last command was a kill    */
  514. #define    CFSRCH    0x0004            /* last command was a search    */
  515.  
  516. #define    SRNORM    0            /* end past, begin front    */
  517. #define    SRBEGIN    1            /* always at front        */
  518. #define    SREND    2            /* always one past end        */
  519.  
  520. #define BELL    0x07            /* a bell character        */
  521. #define    TAB    0x09            /* a tab character        */
  522.  
  523. #if    V7 | USG | SMOS | HPUX | BSD | SUN | XENIX | AVIION
  524. #define    PATHCHR    ':'
  525. #else
  526. #if    WMCS || MPE
  527. #define    PATHCHR ','
  528. #else
  529. #define PATHCHR ';'
  530. #endif
  531. #endif
  532.  
  533. #define INTWIDTH    sizeof(int) * 3
  534.  
  535. /*    Macro argument token types                    */
  536.  
  537. #define TKNUL    0            /* end-of-string        */
  538. #define    TKARG    1            /* interactive argument        */
  539. #define    TKBUF    2            /* buffer argument        */
  540. #define    TKVAR    3            /* user variables        */
  541. #define    TKENV    4            /* environment variables    */
  542. #define    TKFUN    5            /* function....            */
  543. #define    TKDIR    6            /* directive            */
  544. #define    TKLBL    7            /* line label            */
  545. #define    TKLIT    8            /* numeric literal        */
  546. #define    TKSTR    9            /* quoted string literal    */
  547. #define    TKCMD    10            /* command name            */
  548.  
  549. /*    Internal defined functions                    */
  550.  
  551. #define nextab(a)    (a - (a % tabsize)) + tabsize
  552.  
  553. /* DIFCASE represents the integer difference between upper
  554.    and lower case letters.  It is an xor-able value, which is
  555.    fortunate, since the relative positions of upper to lower
  556.    case letters is the opposite of ascii in ebcdic.
  557. */
  558.  
  559. #ifdef    islowerz
  560. #undef    islowerz
  561. #endif
  562. #ifdef    isupperz
  563. #undef    isupperz
  564. #endif
  565.  
  566. #if    ASCII
  567. #define    DIFCASE     0x20
  568. #else
  569. #define DIFCASE        0x40
  570. #endif
  571.  
  572. /* and keep the new sun compiler happy.... */
  573. #if    SUN
  574. #undef    isupperz
  575. #undef    islowerz
  576. #define    isupperz(a)    isucase(a)
  577. #define    islowerz(a)    islcase(a)
  578. #endif
  579.  
  580. /*    Dynamic RAM tracking and reporting redefinitions    */
  581.  
  582. #if    RAMSIZE
  583. #define    malloc    allocate
  584. #define    free    release
  585. #else
  586. #if    VMS & OPTMEM
  587. #define malloc     VAXC$MALLOC_OPT
  588. #define free    VAXC$FREE_OPT
  589. #define calloc    VAXC$CALLOC_OPT
  590. #define realloc VAXC$REALLOC_OPT
  591. #define cfree   VAXC$CFREE_OPT
  592. #endif
  593. #endif
  594.  
  595. /*
  596.  * There is a window structure allocated for every active display window. The
  597.  * windows are kept in a big list, in top to bottom screen order, with the
  598.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  599.  * The flag field contains some bits that are set by commands to guide
  600.  * redisplay. Although this is a bit of a compromise in terms of decoupling,
  601.  * the full blown redisplay is just too expensive to run for every input
  602.  * character.
  603.  */
  604. typedef struct    WINDOW {
  605.     struct    WINDOW *w_wndp;     /* Next window            */
  606.     struct    BUFFER *w_bufp;     /* Buffer displayed in window    */
  607.     struct    LINE *w_linep;        /* Top line in the window    */
  608.     struct    LINE *w_dotp;        /* Line containing "."        */
  609.     short    w_doto;         /* Byte offset for "."        */
  610.     struct    LINE *w_markp[NMARKS];    /* Line containing "mark"    */
  611.     short    w_marko[NMARKS];    /* Byte offset for "mark"    */
  612.     char    w_toprow;        /* Origin 0 top row of window    */
  613.     char    w_ntrows;        /* # of rows of text in window    */
  614.     char    w_force;        /* If NZ, forcing row.        */
  615.     char    w_flag;         /* Flags.            */
  616. #if    COLOR
  617.     char    w_fcolor;        /* current forground color      */
  618.     char    w_bcolor;        /* current background color    */
  619. #endif
  620.     int    w_fcol;         /* first column displayed    */
  621. }    WINDOW;
  622.  
  623. #define WFFORCE 0x01            /* Window needs forced reframe    */
  624. #define WFMOVE    0x02            /* Movement from line to line    */
  625. #define WFEDIT    0x04            /* Editing within a line    */
  626. #define WFHARD    0x08            /* Better to a full display    */
  627. #define WFMODE    0x10            /* Update mode line.        */
  628. #define    WFCOLR    0x20            /* Needs a color change        */
  629.  
  630. /*
  631.  *    This structure holds the information about each separate "screen"
  632.  * within the current editing session.  On a character based system, these
  633.  * screens overlay each other, and can individually be brought to front.
  634.  * On a windowing system like MicroSoft Windows 3.0, OS/2, the Macintosh,
  635.  * Intuition, Sunview or X-windows, each screen is represented in an OS
  636.  * window.  The terminolgy is wrong in emacs.....
  637.  *
  638.  *    EMACS        The outside World
  639.  *    screen        window
  640.  *    window        pane
  641.  */
  642.  
  643. typedef struct SCREEN {
  644.     struct SCREEN *s_next_screen;    /* link to next screen in list */
  645.     WINDOW *s_first_window;        /* head of linked list of windows */
  646.     WINDOW *s_cur_window;        /* current window in this screen */
  647.     char *s_screen_name;        /* name of the current window */
  648.     short s_roworg;            /* row origin of stored screen */
  649.     short s_colorg;            /* column origin of stored screen */
  650.     short s_nrow;            /* row width of stored screen */
  651.     short s_ncol;            /* column origin of stored screen */
  652. } SCREEN;
  653.  
  654. /*
  655.  * Text is kept in buffers. A buffer header, described below, exists for every
  656.  * buffer in the system. The buffers are kept in a big list, so that commands
  657.  * that search for a buffer by name can find the buffer header. There is a
  658.  * safe store for the dot and mark in the header, but this is only valid if
  659.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  660.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  661.  * the header line in "b_linep"    Buffers may be "Inactive" which means the files associated with them
  662.  * have not been read in yet. These get read in at "use buffer" time.
  663.  */
  664. typedef struct    BUFFER {
  665.     struct    BUFFER *b_bufp;     /* Link to next BUFFER        */
  666.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  667.     short    b_doto;         /* Offset of "." in above LINE    */
  668.     struct    LINE *b_markp[NMARKS];    /* The same as the above two,    */
  669.     short    b_marko[NMARKS];    /* but for the "mark"        */
  670.     int    b_fcol;            /* first col to display        */
  671.     struct    LINE *b_linep;        /* Link to the header LINE    */
  672.     struct    LINE *b_topline;    /* Link to narrowed top text    */
  673.     struct    LINE *b_botline;    /* Link to narrowed bottom text    */
  674.     char    b_active;        /* window activated flag    */
  675.     char    b_nwnd;         /* Count of windows on buffer    */
  676.     char     b_exec;            /* how many active executions    */
  677.     char    b_flag;         /* Flags            */
  678.     int    b_mode;            /* editor mode of this buffer    */
  679.     char    b_fname[NFILEN];    /* File name            */
  680.     char    b_bname[NBUFN];     /* Buffer name            */
  681. #if    CRYPT
  682.     char   b_key[NPAT];           /* current encrypted key        */
  683. #endif
  684. }    BUFFER;
  685.  
  686. #define BFINVS    0x01            /* Internal invisable buffer    */
  687. #define BFCHG    0x02            /* Changed since last write    */
  688. #define    BFTRUNC    0x04            /* buffer was truncated when read */
  689. #define    BFNAROW    0x08            /* buffer has been narrowed    */
  690.  
  691. /*    mode flags    */
  692. #define    NUMMODES    10           /* # of defined modes           */
  693.  
  694. #define MDWRAP    0x0001            /* word wrap            */
  695. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  696. #define    MDSPELL    0x0004            /* spell error parsing        */
  697. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  698. #define    MDVIEW    0x0010            /* read-only buffer        */
  699. #define MDOVER    0x0020            /* overwrite mode        */
  700. #define MDMAGIC    0x0040            /* regular expresions in search */
  701. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  702. #define    MDASAVE    0x0100            /* auto-save mode        */
  703. #define    MDREPL    0x0200            /* replace mode            */
  704.  
  705. /*
  706.  * The starting position of a region, and the size of the region in
  707.  * characters, is kept in a region structure.  Used by the region commands.
  708.  */
  709. typedef struct    {
  710.     struct    LINE *r_linep;        /* Origin LINE address.     */
  711.     short    r_offset;        /* Origin LINE offset.        */
  712.     long    r_size;         /* Length in characters.    */
  713. }    REGION;
  714.  
  715. /*
  716.  * All text is kept in circularly linked lists of "LINE" structures. These
  717.  * begin at the header line (which is the blank line beyond the end of the
  718.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  719.  * number of bytes in the line (the "used" size), the size of the text array,
  720.  * and the text. The end of line is not stored as a byte; it's implied.
  721.  */
  722. typedef struct    LINE {
  723.     struct    LINE *l_fp;        /* Link to the next line    */
  724.     struct    LINE *l_bp;        /* Link to the previous line    */
  725.     short    l_size;         /* Allocated size        */
  726.     short    l_used;         /* Used size            */
  727.     char    l_text[1];        /* A bunch of characters.    */
  728. }    LINE;
  729.  
  730. #define lforw(lp)    ((lp)->l_fp)
  731. #define lback(lp)    ((lp)->l_bp)
  732. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  733. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  734. #define llength(lp)    ((lp)->l_used)
  735.  
  736. /*
  737.  * The editor communicates with the display using a high level interface. A
  738.  * "TERM" structure holds useful variables, and indirect pointers to routines
  739.  * that do useful operations. The low level get and put routines are here too.
  740.  * This lets a terminal, in addition to having non standard commands, have
  741.  * funny get and put character code too. The calls might get changed to
  742.  * "termp->t_field" style in the future, to make it possible to run more than
  743.  * one terminal type.
  744.  */
  745. typedef struct    {
  746.     short    t_mrow;          /* max number of rows allowable */
  747.     short    t_nrow;         /* current number of rows used    */
  748.     short    t_mcol;         /* max Number of columns.    */
  749.     short    t_ncol;         /* current Number of columns.    */
  750.     short    t_roworg;        /* origin row (normally zero)    */
  751.     short    t_colorg;        /* origin column (normally zero)*/
  752.     short    t_margin;        /* min margin for extended lines*/
  753.     short    t_scrsiz;        /* size of scroll region "    */
  754.     int    t_pause;        /* # times thru update to pause */
  755.     VOID (PASCAL NEAR *t_open)(VOID);    /* Open terminal at the start.    */
  756.     VOID (PASCAL NEAR *t_close)(VOID);    /* Close terminal at end.    */
  757.     VOID (PASCAL NEAR *t_kopen)(VOID);    /* Open keyboard        */
  758.     VOID (PASCAL NEAR *t_kclose)(VOID);    /* close keyboard        */
  759.     int (PASCAL NEAR *t_getchar)(VOID);    /* Get character from keyboard. */
  760.     VOID (PASCAL NEAR *t_putchar)(int);    /* Put character to display.    */
  761.     VOID (PASCAL NEAR *t_flush)(VOID);    /* Flush output buffers.    */
  762.     VOID (PASCAL NEAR *t_move)(int, int);    /* Move the cursor, origin 0.    */
  763.     VOID (PASCAL NEAR *t_eeol)(VOID);    /* Erase to end of line.    */
  764.     VOID (PASCAL NEAR *t_eeop)(VOID);    /* Erase to end of page.    */
  765.     VOID (PASCAL NEAR *t_clrdesk)(VOID);    /* Clear the page totally    */
  766.     VOID (PASCAL NEAR *t_beep)(VOID);    /* Beep.            */
  767.     VOID (PASCAL NEAR *t_rev)(int);        /* set reverse video state    */
  768.     int (PASCAL NEAR *t_rez)(int);        /* change screen resolution    */
  769. #if    COLOR
  770.     VOID (PASCAL NEAR *t_setfor)(int);     /* set forground color        */
  771.     VOID (PASCAL NEAR *t_setback)(int);    /* set background color        */
  772. #endif
  773. #if    INSDEL
  774.     int (PASCAL NEAR *t_insline)();    /* insert a screen line        */
  775.     int (PASCAL NEAR *t_delline)();    /* delete a screen line        */
  776. #endif
  777. }    TERM;
  778.  
  779. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  780.                         dependant place later) */
  781.  
  782. #define TTopen        (*term.t_open)
  783. #define    TTclose        (*term.t_close)
  784. #define    TTkopen        (*term.t_kopen)
  785. #define    TTkclose    (*term.t_kclose)
  786. #define    TTgetc        (*term.t_getchar)
  787. #define    TTputc        (*term.t_putchar)
  788. #define    TTflush        (*term.t_flush)
  789. #define    TTmove        (*term.t_move)
  790. #define    TTeeol        (*term.t_eeol)
  791. #define    TTeeop        (*term.t_eeop)
  792. #define    TTclrdesk    (*term.t_clrdesk)
  793. #define    TTbeep        (*term.t_beep)
  794. #define    TTrev        (*term.t_rev)
  795. #define    TTrez        (*term.t_rez)
  796. #if    COLOR
  797. #define    TTforg        (*term.t_setfor)
  798. #define    TTbacg        (*term.t_setback)
  799. #endif
  800.  
  801. /*    Structure for the table of current key bindings     */
  802.  
  803. ETYPE EPOINTER {
  804.     int (PASCAL NEAR *fp)();    /* C routine to invoke */
  805.     BUFFER *buf;            /* buffer to execute */
  806. };
  807.  
  808. typedef struct    {
  809.     short k_code;         /* Key code            */
  810.     short k_type;        /* binding type (C function or EMACS buffer) */
  811.     ETYPE EPOINTER k_ptr;    /* ptr to thing to execute */
  812. }    KEYTAB;
  813.  
  814. /*    structure for the name binding table        */
  815.  
  816. typedef struct {
  817.     char *n_name;            /* name of function key */
  818.     int (PASCAL NEAR *n_func)();    /* function name is bound to */
  819. }    NBIND;
  820.  
  821. /*    The editor holds deleted text chunks in the KILL buffer. The
  822.     kill buffer is logically a stream of ascii characters, however
  823.     due to its unpredicatable size, it gets implemented as a linked
  824.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  825.     was taken up by the keycode structure)
  826. */
  827.  
  828. typedef struct KILL {
  829.     struct KILL *d_next;   /* link to next chunk, NULL if last */
  830.     char d_chunk[KBLOCK];    /* deleted text */
  831. } KILL;
  832.  
  833. /*    When emacs' command interpetor needs to get a variable's name,
  834.     rather than it's value, it is passed back as a VDESC variable
  835.     description structure. The v_num field is a index into the
  836.     appropriate variable table.
  837. */
  838.  
  839. typedef struct VDESC {
  840.     int v_type;    /* type of variable */
  841.     int v_num;    /* ordinal pointer to variable in list */
  842. } VDESC;
  843.  
  844. /*    The !WHILE directive in the execution language needs to
  845.     stack references to pending whiles. These are stored linked
  846.     to each currently open procedure via a linked list of
  847.     the following structure
  848. */
  849.  
  850. typedef struct WHBLOCK {
  851.     LINE *w_begin;        /* ptr to !while statement */
  852.     LINE *w_end;        /* ptr to the !endwhile statement*/
  853.     int w_type;        /* block type */
  854.     struct WHBLOCK *w_next;    /* next while */
  855. } WHBLOCK;
  856.  
  857. #define BTWHILE     1
  858. #define    BTBREAK        2
  859.  
  860.  
  861. /* HICHAR - 1 is the largest character we will deal with.
  862.  * HIBYTE represents the number of bytes in the bitmap.
  863.  */
  864. #define HICHAR        256
  865. #if OS2
  866. #define    HIBYTE_        HICHAR >> 3
  867. #else
  868. #define    HIBYTE        HICHAR >> 3
  869. #endif
  870.  
  871. #if    MAGIC
  872. /*
  873.  * Defines for the metacharacters in the regular expression
  874.  * search routines.  MCNIL and LITCHAR are used in both search
  875.  * and replace metachar-arrays.
  876.  */
  877. #define MCNIL        0    /* Like the '\0' for strings.*/
  878. #define    LITCHAR        1    /* Literal character, or string.*/
  879. #define    ANY        2
  880. #define    CCL        3
  881. #define    NCCL        4
  882. #define    BOL        5
  883. #define    EOL        6
  884. #define    GRPBEG        0x0010    /* Toggle-able value for group begin.*/
  885. #define    GRPEND        0x0020    /* Toggle-able value for group end.*/
  886.  
  887. #define    DITTO        2    /* Replacement #define.*/
  888. #define GROUP        3    /* Replacement #define.*/
  889.  
  890. #define    CLOSURE        0x0100    /* An or-able value for a closure modifier.*/
  891. #define    CLOSURE_1    0x0200    /* An or-able value for a closure modifier.*/
  892. #define    ZEROONE        0x0400    /* An or-able value for a closure modifier.*/
  893.  
  894. #define ALLCLOS        (CLOSURE | CLOSURE_1 | ZEROONE)
  895. #define    MASKCLO        (~ALLCLOS)
  896.  
  897. #define MC_ANY        '.'    /* 'Any' character (except newline).*/
  898. #define    MC_CCL        '['    /* Character class.*/
  899. #define    MC_NCCL        '^'    /* Negate character class.*/
  900. #define    MC_RCCL        '-'    /* Range in character class.*/
  901. #define    MC_ECCL        ']'    /* End of character class.*/
  902. #define    MC_BOL        '^'    /* Beginning of line.*/
  903. #define    MC_EOL        '$'    /* End of line.*/
  904. #define    MC_CLOSURE    '*'    /* Closure - zero to many characters match.*/
  905. #define    MC_CLOSURE_1    '+'    /* Closure - one to many characters match.*/
  906. #define    MC_ZEROONE    '?'    /* Closure - zero to one characters match.*/
  907. #define    MC_DITTO    '&'    /* Use matched string in replacement.*/
  908. #define MC_GRPBEG    '('    /* Start of group (begun with a backslash).*/
  909. #define MC_GRPEND    ')'    /* End of group (begun with a backslash).*/
  910. #define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  911.  
  912. #define MAXGROUPS    10        /* 1 + maximum # of r. e. groups. */
  913. #define BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  914.  
  915. /* Typedefs that define the bitmap type for searching (meBITMAP),
  916.  * the meta-character structure for MAGIC mode searching (MC),
  917.  * and the meta-character structure for MAGIC mode replacment (RMC).
  918.  */
  919. typedef char    *meBITMAP;
  920.  
  921. typedef struct {
  922.     short int    mc_type;
  923.     union {
  924.         int    lchar;
  925.         int    group_no;
  926.         meBITMAP    cclmap;
  927.     } u;
  928. } MC;
  929.  
  930. typedef struct {
  931.     short int      mc_type;
  932.     union {
  933.         int    group_no;
  934.         char    *rstr;
  935.     } u;
  936. } RMC;
  937. #endif
  938.  
  939. /*
  940.     This is the message which should be added to any "About MicroEMACS"
  941.     boxes on any of the machines with window managers.
  942.  
  943.  
  944.     ------------------------------------------
  945.     |                     |
  946.     |     MicroEMACS v3.xx         |
  947.     |        for the ............     |
  948.     |                     |
  949.     |    Text Editor and Corrector         |
  950.     |                     |
  951.     |    written by Daniel M. Lawrence     |
  952.     |    [based on code by Dave Conroy]     |
  953.     |                     |
  954.     |    Send inquiries and donations to:     |
  955.     |    617 New York St             |
  956.     |    Lafayette, IN 47901         |
  957.     |                     |
  958.     ------------------------------------------
  959. */
  960.